package com.xcc.service;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xcc.mapper.BaseMapper;
import com.xcc.model.BaseModel;
import com.xcc.model.BaseReponeModel;
import com.xcc.model.Page;
import com.xcc.model.TableBaseModel;
import com.xcc.model.UpdateModel;


public abstract class BaseServiceImp<T extends BaseMapper,M extends BaseModel> implements BaseService<M>{

	@Autowired
	T mBaseMapper;

	BaseReponeModel mBaseReponeModel=new BaseReponeModel();

	/*	
	@Override
	public Object getMember(Page mPage) {
		PageUser m=new PageUser();
		m.setMember(mBaseMapper.getPageMagament(mPage));
		m.setTotal(mBaseMapper.getTotal());
		mBaseReponeModel.setData(m);
		return mBaseReponeModel;
	}
	 */
	@Override
	public Object getMember(Page mPage) {
		TableBaseModel mTableBaseModel=  new TableBaseModel();
		mTableBaseModel.setRows(mBaseMapper.getPageMagament(mPage));
		mTableBaseModel.setTotal(mBaseMapper.getTotal()+"");
		return mTableBaseModel;
	}

	@Override
	public Object selectName(UpdateModel<M> mBookMagaments) {
		TableBaseModel mTableBaseModel=  new TableBaseModel();
		List<M> m=mBaseMapper.selectName(mBookMagaments);
		mTableBaseModel.setRows(m);
		mTableBaseModel.setTotal(mBaseMapper.selectNameTotal(mBookMagaments)+"");
		return mTableBaseModel;
	}

	@Override
	public Object add(UpdateModel<M> Model) {
		Page mPage =Model.getmPage();
		M mBaseModel= Model.getmMagament();
		return mBaseMapper.insertSelective(mBaseModel);
	}

	@Override
	public Object deleteByPrimaryKey(UpdateModel<M> mAddModel) {
		BaseReponeModel mBaseReponeModel =new BaseReponeModel();
		mBaseReponeModel.setData(mBaseMapper.deleteByPrimaryKey(mAddModel.getmMagament().getId()));
		return mBaseReponeModel;
	}

	@Override
	public Object updateByPrimaryKeySelective(UpdateModel<M> mAddModel) {
		BaseReponeModel mBaseReponeModel =new BaseReponeModel();
		mBaseReponeModel.setData(mBaseMapper.updateByPrimaryKeySelective(mAddModel.getmMagament())+"");
		return mBaseReponeModel;
	}
	
	@Override
	public Object insertlist(List<M> mListObjects) {
		 mBaseMapper.insertlist(mListObjects);
		 return mListObjects;
	}
	
	@Override
	public Object insertSelective(M mListObjects) {
		BaseReponeModel mBaseReponeModel =new BaseReponeModel();
		mBaseReponeModel.setMessage(mBaseMapper.insertSelective(mListObjects)+"");	 
		return mBaseReponeModel;
	}






}
